/*
 * @FileName: 
 * @Version: 
 * @Author: 王杨洋
 * @Date: 2021-06-11 18:28:13
 */
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include <unistd.h>
#include <stdarg.h>
#include "../include/message.h"
#include "../include/device_manage.h"
#include "../include/media.h"
#define NAME_PASSWORD_LEN 128

int main(int argc, const char *argv[])
{
	int mediaSockFd = -1;

	struct sockaddr_in serveraddr;
	int cmd;
	MsgStruct msg;
	memset(&msg, 0x0, sizeof(MsgStruct));

	char name[NAME_PASSWORD_LEN] = "yy";
	char focusMac[32] = "02:11:22:33:44:55:66:77";
	const char sourceIp[32] = "127.0.0.1";

	//5.Connect Media Service
	if((mediaSockFd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
	{
		perror("fail to socket.\n");
		return -1;
	}

	bzero(&serveraddr, sizeof(serveraddr));
	serveraddr.sin_family = AF_INET;
	serveraddr.sin_addr.s_addr = inet_addr(sourceIp);
	serveraddr.sin_port = htons(SERVER_MEDIA_PORT);

	if(connect(mediaSockFd, (struct sockaddr *)&serveraddr, sizeof(serveraddr)) < 0)
	{
		perror("fail to connect");
		return -1;
	}

    	printf("**************************REFRIGERATOR***************************\n");
		printf("*                       	5.Video                             *\n");
		printf("*****************************************************************\n");
		printf("Please choose:");
		scanf("%d", &cmd);
		getchar();

		if (cmd == 5) {
			PlayVideo(mediaSockFd, name, focusMac);
		}
	return 0;
}